// Package user 存放角色 Model 相关逻辑
package role

import (
	"gohub/app/models"
	"gohub/pkg/database"
)

// Role 用户模型
type Role struct {
	models.BaseModel

	Title    string `json:"title,omitempty"`
	Describe string `json:"describe,omitempty"`

	models.CommonTimestampsField
}

// func (Role) TableName() string {
// 	return "admin_roles"
// }

// Create 创建用户，通过 Role.ID 来判断是否创建成功
func (roleModel *Role) Create() {
	database.DB.Create(&roleModel)
}

func (roleModel *Role) Save() (rowsAffected int64) {
	result := database.DB.Save(&roleModel)
	return result.RowsAffected
}
